package com.xq.model;

import java.util.List;

public class Topic extends BaseModel<Topic>
{

    public final static String TABLE_NAME = "xq_topic";
    public final static Topic dao = new Topic();

    /**
     * 查找帖子
     * 
     * @param start
     * @param limit
     * @param xiaoQuId
     * @return List<Topic>
     */
    public List<Topic> findXiaoQuId(int start, int limit, int xiaoQuId)
    {
        String sql = "select a.id,a.title,a.content,a.type,a.userId,a.sendTime,a.readNum,a.feedbackNum,b.nick,b.portrait from xq_topic a, xq_user b"
                + " where a.xiaoQuId = ? and a.parentId is null order by a.sendTime desc limit ?,?;";
        Object params[] = new Object[3];
        params[0] = xiaoQuId;
        params[1] = start;
        params[2] = limit;
        return find(sql, params);
    }
    
    public List<Topic> findByTopicId(int start, int limit, int topicId){
        String sql = "select a.id,a.title,a.content,a.type,a.userId,a.sendTime,a.readNum,a.feedbackNum,b.nick,b.portrait from xq_topic a, xq_user b"
                + " where a.parentId =? order by a.sendTime limit ?,?;";
        Object params[] = new Object[3];
        params[0] = topicId;
        params[1] = start;
        params[2] = limit;
        return find(sql, params);
    }
}
